package org.example.protocol;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * @author WZW
 * @date 2020/7/11
 */
public class RacingCarEncoder extends MessageToByteEncoder<RacingCarProtocol> {
    @Override
    protected void encode(ChannelHandlerContext ctx, RacingCarProtocol msg, ByteBuf out) throws Exception {
        out.writeInt(msg.getHead());
        out.writeInt(msg.getLength());
        out.writeBytes(msg.getContent());
    }
}
